import { ElementEntity } from './ElementEntity';
import { COLOR, formarColor, CreatePosition } from '../Config'


class PolygonEntity extends ElementEntity {
    constructor(options = {}) {
        super(options.id, options, options.onClick, options.onRightClick);
        this.EntityTypeName = 'ElementEntity'
        this.color = formarColor(options.color) || COLOR.MarkViewColor;
        this.lineWidth = options.lineWidth || 0;
        this.lineColor = formarColor(options.lineColor) || COLOR.LOCATIONCOVER;
        this.Points = [];
        this.height = options.height || 1000;
        for (let i = 0; i < options.points.length; i++) {
            const element = options.points[i];
            this.Points.push(CreatePosition(element));
        };
        this.Entity.polygon = {
            hierarchy: { positions: this.Points },
            material: this.color,
            arcType: Cesium.ArcType.GEODESIC,
            height: this.height,
            outline: !!this.lineWidth,
            outlineColor: this.lineColor,
            outlineWidth: this.lineWidth,
        };
    }
}

export default PolygonEntity